package com.my.reactor.basic;


import com.my.reactor.basic.bean.User;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author: marshal
 * @date: 2022-11-02 14:01
 */
public class Part4Transform {
    //========================================================================================

    // TODO Capitalize the user username, firstname and lastname
    Mono<User> capitalizeOne(Mono<User> mono) {
        return mono.flatMap(user -> {
            user.getFirstname().toUpperCase();
            user.getLastname().toUpperCase();
            user.getUsername().toUpperCase();
            return Mono.just(user);
        });
    }

//========================================================================================

    // TODO Capitalize the users username, firstName and lastName
    Flux<User> capitalizeMany(Flux<User> flux) {
        return null;
    }

//========================================================================================

    // TODO Capitalize the users username, firstName and lastName using #asyncCapitalizeUser
    Flux<User> asyncCapitalizeMany(Flux<User> flux) {
        return null;
    }

    Mono<User> asyncCapitalizeUser(User u) {
        return Mono.just(new User(u.getUsername().toUpperCase(), u.getFirstname().toUpperCase(), u.getLastname().toUpperCase()));
    }
}
